import Taro from '@tarojs/taro'


export function httpRequest(url, method, data){
    return new Promise( (res, rej) => {
        Taro.request({
            url: url,
            method: method,
            data: data,
            success(pos){
                res(pos)
            },
            fail(err){
                rej(err)
            },
            complete(){
                Taro.hideLoading()
            }
        })
    })
}
export function get(url, data){
    return httpRequest(url, 'GET', data)
}
export function post(url, data){
    return httpRequest(url, 'POST', data)
}
export default {
    httpRequest,
    post,
    get
}